package com.tree.commonutil.csv;

import com.opencsv.CSVReader;
import com.tree.commonutil.MultipartFileUtil;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName CsvDemo4
 * @Description: TODO
 * @Author: myl
 * @Create_time:2021/5/7 16:18
 */
public class CsvDemo4 {
    public static void main(String[] args) throws Exception {
        File file = new File("D:\\document\\download-context\\bop副本.csv");
        FileInputStream input = new FileInputStream(file);
        MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", input);

        File file1 = MultipartFileUtil.multipartFileToFile(multipartFile);


        CSVReader reader = new CSVReader(new FileReader(file1));

        List<String[]> myEntries = reader.readAll();

        myEntries.forEach(item -> System.out.println(Arrays.toString(item)));



    }
}
